package consoleView;

import java.io.IOException;
import model.FileHandler;
import model.Puzzle;


/*
 * Created on Mar 31, 2005
 * Modified January 24, 2006
 */

/**
 * @author Beth Katz
  * 
 */
public class ConsoleController {
	
    private Puzzle thePuzzle;
    private ConsoleUI theUI;

	
    /**
     * Constructor for WordSearch class.
     * Prompts for and reads puzzle
     */
    public ConsoleController( ) throws IOException {
    	theUI = new ConsoleUI( );
    	String fileName = theUI.obtainFileName("Please enter a file name:");
       	thePuzzle = new Puzzle(FileHandler.matrixFromFileName(fileName));
       	theUI.setPuzzle(thePuzzle);
    }
    
    public void run ( ) {
    	theUI.printPuzzle();
    	theUI.findWords();
    }

	public static void main(String[] args) {
        ConsoleController p = null;
        
        try {
            p = new ConsoleController();
        } catch( IOException e ) {
            System.out.println( "IO Error: " );
            e.printStackTrace( );
            return;
        }
        p.run( );

   	}

}
